package com.imu.purse.config;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Properties;

/**
 * 生成验证码配置
 * @author sunhongwei
 * @email sunhongwei@gmail.com
 * @date 2017年11月4日 上午11:07:35
 */
@Configuration
public class KaptchaConfig 
{

    @Bean
    public DefaultKaptcha producer()
    {
        Properties properties = new Properties();
        properties.put("kaptcha.border", "no");
        properties.put("kaptcha.image.width", "236");
        properties.put("kaptcha.image.height", "46");
        properties.put("kaptcha.noise.color", "153,50,204");
        properties.put("kaptcha.textproducer.font.color", "white");
        properties.put("kaptcha.textproducer.char.space", "5");
        properties.put("kaptcha.background.clear.from", "92,189,170");
        properties.put("kaptcha.background.clear.to", "22,160,133");
        Config config = new Config(properties);
        DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
        defaultKaptcha.setConfig(config);
        return defaultKaptcha;
    }
}
